<template>
  <base-breadcrumb :breadcrumb="!isAudit">
    <template>
      <a-card>
        <titleName title="信息详情" />
        <a-form-model
          ref="ruleForm"
          :model="form"
          :hide-required-mark="true"
          :label-col="{ lg: { span: 6 }, sm: { span: 6 } }"
          :wrapper-col="{ lg: { span: 16 }, sm: { span: 16 } }"
        >
          <a-row :gutter="24">
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-model-item label="名称：">
                <span>{{ form.name }}</span>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-model-item label="所属项目：">
                <span>{{ form.projectName }}</span>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-model-item label="所属分公司：">
                <span>{{ form.branchComName }}</span>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-model-item
                label="分包商名称："
                prop="branchComId"
              >
                <span>{{ form.subContractorName }}</span>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-model-item
                label="编号："
                prop="branchComId"
              >
                <span>{{ form.number }}</span>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-model-item
                label="施工范围："
                prop="branchComId"
              >
                <span>{{ form.constructionRange }}</span>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-model-item
                label="计量月份"
                prop="measureMonth"
              >
                <span>{{ form.measureMonth }}</span>
              </a-form-model-item>
            </a-col>
            <!-- <a-col :md="8" :sm="8">
                            <a-form-model-item label="当前状态：" prop="branchComId">
                                <span v-show="status == 'form.DRAFT'">草稿</span>
                                <span v-show="form.status === 'SUBMITTED'">已提交</span>
                                <span v-show="form.status === 'PAST'">通过</span>
                                <span v-show="form.status === 'SIGNSTATUS'">会签中</span>
                                <span v-show="form.status === 'REJECTED'">驳回</span>
                                <span v-show="form.status === 'DELETE'">已删除</span>
                            </a-form-model-item>
                        </a-col> -->
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-model-item
                label="填报人："
                prop="branchComId"
              >
                <span>{{ form.creatorName }}</span>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-model-item
                label="填报时间："
                prop="branchComId"
              >
                <span>{{ form.createTime }}</span>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-model-item label="截止2016年4月30日累计含税金额(元)：">
                <span>{{ form.yearAmount }}</span>
              </a-form-model-item>
            </a-col>
            <a-col
              :md="8"
              :sm="8"
            >
              <a-form-model-item
                label="附件："
                prop="branchComId"
              >
                <div class="f-col">
                  <file-link :file-list="form.fileInfoVOList" />
                  <file-link :file-list="form.reviewFileInfoVOList" />
                </div>
              </a-form-model-item>
            </a-col>
            <!-- <a-col :md="24" :sm="24">
                            <a-form-model-item label="a.至上月累计金额（含税）：" prop="name">
                                <span>{{ form.toLastMonthCumulativeAmount }}</span>
                            </a-form-model-item>
                        </a-col> -->
            <a-col
              :md="24"
              :sm="24"
              class="mb-24"
            >
              <a-row
                type="flex"
                align="middle"
              >
                <a-col
                  :md="2"
                  :sm="2"
                  class="tx-center"
                >
                  完成工作量
                </a-col>
                <a-col
                  :md="16"
                  :sm="16"
                >
                  <div id="components-table-demo-size">
                    <h4>本月</h4>
                    <a-table
                      :columns="columns"
                      :data-source="form.workloadDetailDTO"
                      size="middle"
                      bordered
                      :pagination="false"
                    />
                  </div>
                </a-col>
              </a-row>
            </a-col>
            <!-- <a-col :md="24" :sm="24">
                            <a-form-model-item label="a+b.至本月累计金额（含税）(元)" prop="name">
                                <BaseInput
                                    disabled
                                    placeholder="a+b.至本月累计金额（含税）(元)"
                                    v-model="form.cumulativeAmount"
                                />
                            </a-form-model-item>
                        </a-col> -->
            <a-col
              :md="24"
              :sm="24"
            >
              <a-form-model-item
                label="分包上报完成形象部位："
                prop="name"
              >
                <BaseTextarea
                  v-model="form.completePart"
                  disabled
                  placeholder="请输入"
                />
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </a-card>

      <div class="tool-btns mb20">
        <a-button
          v-if="checkVisibleInDetail"
          type="primary"
          @click="closeForm"
        >
          关闭
        </a-button>
      </div>
    </template>
  </base-breadcrumb>
</template>
<script>
import { getStepOneDetail } from '@/api/businessAffairs/sml'
import Vue from 'vue'
import { isAttachment ,checkVisibleInDetail} from '@/utils/util'
const columns = [
    {
        title: '项目/金额',
        dataIndex: 'name',
        scopedSlots: { customRender: 'project_amount' },
    },
    {
        title: '1、不含增值税金额(元)',
        dataIndex: 'amountExTax',
        scopedSlots: { customRender: 'amountExTax' },
    },
    {
        title: '2、增值税(元)',
        dataIndex: 'tax',
        scopedSlots: { customRender: 'tax' },
    },
    {
        title: '小计（1+2）(元)',
        dataIndex: 'totalOf',
        scopedSlots: { customRender: 'totalOf' },
    },
    {
        title: '备注',
        dataIndex: 'remark',
        scopedSlots: { customRender: 'remark' },
    },
]

export default {
    name:'a'+Date.now(),
    data() {
        this.columns = columns
        return {
             checkVisibleInDetail:checkVisibleInDetail(this),
            form: {},
            token: '',
        }
    },
    props: {
        isAudit: {
            // 是否作为审批详情
            type: Boolean,
            default: false,
        },
    },
    watch: {
        isAudit: {
            immediate: true,
            handler(val) {
                if (val) {
                    this.$nextTick(() => {
                        this.type = 'look'
                    })
                }
            },
        },
    },
    mounted() {
        this.token = Vue.getAcloudProvider().getAccessToken()
        if (this.$route.query.id) {
            this.id = this.$route.query.id
            console.log(this.id)
            this.isUpdate = false
            this.getStepOneDetail()
        }
    },

    methods: {
        getStepOneDetail() {
            let params = {
                id: this.id,
            }
            getStepOneDetail(params).then((res) => {
                console.log(res)
                this.isUpdate = true
                this.form = res.data
                if (this.form.monthDetailList != null) {
                    this.form.totalAmount =
                        parseFloat(this.form.monthDetailList[this.form.monthDetailList.length - 1].totalOf) +
                        parseFloat(this.form.toLastMonthCumulativeAmount)
                }
            })
        },

        // 关闭表单
        closeForm() {
            if (this.isAudit) {
                window.close()
            } else {
                this.$multiTab.close(this.$route.fullpath)
            }
        },
    },
}
</script>
<style lang="less" scoped>
@deep: ~'>>>';
.tool-btns {
    display: flex;
    justify-content: flex-end;
    @{deep} .ant-btn + .ant-btn {
        margin-left: 12px;
    }
}
.step-text {
    .ant-steps-item-title {
        width: 168px;
    }
}
.f-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
}
.f-col .ant-form-item-label {
    text-align: left;
}
.mb-24 {
    margin-bottom: 24px;
}
.check-box {
    .ant-checkbox-group {
        margin-top: 1.5%;
        display: flex;
        justify-content: space-between;
    }
    .ant-checkbox-group-item {
        position: static !important;
    }
}
.radio-box {
    .ant-radio-wrapper {
        position: static !important;
    }
    .ant-radio-group {
        margin-top: 3% !important;
        display: flex;
    }
}
h4 {
    text-align: center;
}
.foot-btn {
    display: flex;
    justify-content: space-between;
}
.my-table {
    border: 1px solid #e6e6e6;
}
.tx-center {
    text-align: center;
}
</style>